﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using ModuleDALCore;
using DTO;

namespace DAL
{
	public class LICHHENDAO:DALBase
	{
		public LICHHENDAO()
		{
			this.OpenConnect();
		}
		private DataTable dt;
		private string _SpName;

		public string SpName
		{
			get { return "SPLICHHENW"; }
			set { _SpName = value; }
		}
		public DataTable GetListLH()
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LICHHEN(), null), ConvertClassToArray.GetValues(new LICHHEN(), 0));
				return dt;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LH"); }
		}
		public List<LICHHEN> GetListLHS()
		{
			dt = new DataTable();
			List<LICHHEN> LH = new List<LICHHEN>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LICHHEN(), null), ConvertClassToArray.GetValues(new LICHHEN(), 0));
				LH = (List<LICHHEN>)ConvertDatatableToList.ConvertTo<LICHHEN>(dt);
				return LH;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LH"); }
		}
		public List<LICHHEN> Find(LICHHEN lh)
		{
			dt = new DataTable();
			List<LICHHEN> LH = new List<LICHHEN>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(lh, null), ConvertClassToArray.GetValues(lh, 6));
				LH = (List<LICHHEN>)ConvertDatatableToList.ConvertTo<LICHHEN>(dt);
				return LH;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LH"); }
		}
		public DataTable FindDate(LICHHEN lh)
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(lh, null), ConvertClassToArray.GetValues(lh, 8));
				return dt;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LH"); }
		}
		public List<LICHHEN> GETALL(LICHHEN lh)
		{
			dt = new DataTable();
			List<LICHHEN> LH = new List<LICHHEN>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(lh, null), ConvertClassToArray.GetValues(lh, 7));
				LH = (List<LICHHEN>)ConvertDatatableToList.ConvertTo<LICHHEN>(dt);
				return LH;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LH"); }
		}
		public String CreatenewId()
		{
			try
			{
				return "LH" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new LICHHEN(), null), ConvertClassToArray.GetValues(new LICHHEN(), 1));

			}
			catch { return null; }// throw new InvalidExpressionException("Msg1: Can't Create new LH"); }
		}
		public bool INSERT(LICHHEN NH)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(NH, null), ConvertClassToArray.GetValues(NH, 1)) == 1);

			}
			catch { return false; }// throw new InvalidExpressionException("Msg1: Can't Insert new LH"); }
		}
		public bool UPDATE(LICHHEN NH)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(NH, null), ConvertClassToArray.GetValues(NH, 2)) == 1);

			}
			catch { return false; }// throw new InvalidExpressionException("Msg1: Can't Update  LH"); }
		}
		public bool DELETE(LICHHEN NH)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(NH, null), ConvertClassToArray.GetValues(NH, 3)) == 1);

			}
			catch { return false; }// throw new InvalidExpressionException("Msg1: Can't Delete  LH"); }
		}
		public bool ISEXISTS(LICHHEN NH)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(NH, null), ConvertClassToArray.GetValues(NH, 4)) == -1);

			}
			catch { return false; }// throw new InvalidExpressionException("Msg1: Can't Delete  LH"); }
		}
	}
}
